import request from '@/utils/request'

// 商品列表
export function products (data) {
  return request({
    url: '/v1/products',
    method: 'get',
    data
  })
}

// 商品详情
export function productsDetail (id) {
  return request({
    url: `/v1/products/${id}`,
    method: 'get'
  })
}

// 收藏商品
export function getCollection (id) {
  return request({
    url: `/v1/products/${id}/favorite`,
    method: 'post'
  })
}

// 取消商品收藏
export function deleteCollection (id) {
  return request({
    url: `/v1/products/${id}/favorite`,
    method: 'delete'
  })
}

// 获取收藏列表
export function getCollectionList () {
  return request({
    url: '/v1/product_favorites',
    method: 'get'
  })
}

// 优惠券列表
export function getcouponList () {
  return request({
    url:'/v1/coupons',
    method:'get'
  })
}

// 优惠券领取
export function receivecoupon(id){
  return request({
    url:`/v1/coupons/${id}/receive`,
    method:'post'
  })
}

// 用户已领取的优惠券
export function couponUserList(){
  return request({
    url:'/v1/user_coupons',
    method:'get'
  })
}

// 用户可用优惠券
export function couponUserListky(){
  return request({
    url:'/v1/use_user_coupons',
    method:'get'
  })
}